# -*- coding = utf-8 -*-
# @Time : 2021/12/17 14:51
# @Author : 龙王赘婿_彪少
# @File : demo04.py
# @Software: PyCharm

# 指上去就会显示提示的功能
# 和最简单的信号与槽

import sys
from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton, QApplication)
from PyQt5.QtGui import QFont
from PyQt5.QtCore import QCoreApplication


class Example(QWidget):
    def __init__(self):
        # 调用父类构造
        super(Example, self).__init__()
        self.initUI()

    def initUI(self):
        # 设置字体
        QToolTip.setFont(QFont("幼圆", 20))
        self.setToolTip('This is a <b>QWidget</b> widget')

        btn_button = QPushButton("按钮", self)
        btn_button.setToolTip('This is a <b>QPushButton</b> widget')
        btn_button.resize(btn_button.sizeHint())
        btn_button.move(50, 50)

        btn_close = QPushButton("关闭", self)
        btn_close.setToolTip('关闭')
        btn_close.resize(btn_close.sizeHint())
        btn_close.move(50, 100)
        # 信号与槽的绑定
        btn_close.clicked.connect(QCoreApplication.instance().quit)

        self.setGeometry(300, 300, 300, 300)
        self.setWindowTitle("tooltip")
        self.show()


if __name__ == '__main__':
    # 创建app
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
